package com.bosch.in.rtp1.ept.model.dto;

import java.io.Serializable;
import java.util.List;

import com.bosch.in.rtp1.ept.constant.CommonConstants;
import com.bosch.in.rtp1.ept.constant.HoldCodeType;

/**
 * Entity class used to store hold code filter pattern which is specified by user input.
 * Then user is able to search exactly Lots which have hold code matched with the pattern.
 * @author TPR1HC
 *
 */
public class HoldCodeFilter implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/* identifier */
	private int id;

	/* text describle the meaning of patterns */
	private String comment;
	
	/* combination of pattern string used to search Lot */
	private List<String> patterns;
	
	/* order to be displayed in selection box */
	private int order;
	
	/* distinguish HoldCode table with HoldCode reclassified table */
	private HoldCodeType type;

	/**
	 * Get identifier
	 * @return identifier
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * Set identifier
	 * @param id identifier
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Get comment
	 * @return comment
	 */
	public String getComment() {
		return comment;
	}

	/**
	 * Set comment
	 * @param comment
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/**
	 * Get patterns
	 * @return patterns
	 */
	public List<String> getPatterns() {
		return patterns;
	}

	/**
	 * Set patterns
	 * @param patterns
	 */
	public void setPatterns(List<String> patterns) {
		this.patterns = patterns;
	}
	
	/**
	 * Get order
	 * @return order
	 */
	public int getOrder() {
		return order;
	}

	/**
	 * Set order
	 * @param order
	 */
	public void setOrder(int order) {
		this.order = order;
	}
	
	/**
	 * Returns one string representing for all holdcode filter value.
	 * @return
	 */
	public String getPatternsInStr() {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < patterns.size(); i++) {
			sb.append(patterns.get(i));
			
			// add delimiter between holdcode filter value
			if (i < patterns.size() - 1) {
				sb.append(CommonConstants.DELIMITER);
			}
		}
		return sb.toString();
	}

	public HoldCodeType getType() {
		return type;
	}

	public void setType(HoldCodeType type) {
		this.type = type;
	}
	
	public HoldCodeFilter clone() {
		HoldCodeFilter hcFilter = new HoldCodeFilter();
		hcFilter.setId(id);
		hcFilter.setComment(comment);
		hcFilter.setOrder(order);
		hcFilter.setPatterns(patterns);
		hcFilter.setType(type);
		return hcFilter;
	}
	
}
